package cn.qiyu5522.service.impl;

import cn.qiyu5522.constant.SystemConstants;
import cn.qiyu5522.domain.entity.Link;
import cn.qiyu5522.domain.entity.ResponseResult;
import cn.qiyu5522.mapper.LinkMapper;
import cn.qiyu5522.service.LinkService;
import cn.qiyu5522.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 友链 服务实现类
 * </p>
 *
 * @author Tonkey
 * @since 2024-04-11
 */
@Service
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {


    @Override
    public ResponseResult getAllLink() {
        LambdaQueryWrapper<Link> queryWrapper = new LambdaQueryWrapper<>();
        // 查询条件：所有审核通过的友链
        queryWrapper.eq(Link::getStatus, SystemConstants.LINK_STATE_APPROVED);
        List<Link> links = list(queryWrapper);
        List<Link> list = BeanCopyUtils.copyBeanList(links, Link.class);
        return ResponseResult.okResult(list);
    }
}
